package com.jzt.gateway.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jzt.gateway.entity.Account;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * 作者：lizw <br/>
 * 创建时间：2020/06/28 15:46 <br/>
 */
@Repository
@Mapper
public interface AccountDao extends BaseMapper<Account> {

    @Select("select * from account where platform=#{platform} and one_id=#{oneId} limit 1")
    Account getByOneId(@Param("platform") String platform, @Param("oneId") String oneId);

    @Select("select * from account where platform=#{platform} and login_name=#{loginName} limit 1")
    Account getByLoginName(@Param("platform") String platform, @Param("loginName") String loginName);

    @Select("select * from account where platform=#{platform} and telephone=#{telephone} limit 1")
    Account getByTelephone(@Param("platform") String platform, @Param("telephone") String telephone);

    @Update("update account set user_agent_id=#{userAgentId} where one_id=#{oneId} and user_agent_id is null")
    int setUserAgentId(@Param("oneId") String oneId, @Param("userAgentId") String userAgentId);
}
